import request from "@/utils/request";

enum API {
    ALLUSER_URL = '/admin/acl/user/',
    ADDUSER_URL = '/admin/acl/user/save',
    UPDATEUSER_URL = '/admin/acl/user/update',
    ALLROLE_URL = '/admin/acl/user/toAssign/',
    SETROLE_URL = '/admin/acl/user/doAssignRole',
    DELETEUSER_URL = '/admin/acl/user/remove/',
    DELETEALLUSER_URL = '/admin/acl/user/batchRemove'
}

// 获取用户账号信息的接口
export const reqUserInfo = (page: any, limit: any, username: any) => request.get<any, any>(API.ALLUSER_URL + `${page}/${limit}/?username=${username}`)

// 添加用户和更新已有用户的接口
export const reqAddOrUpdateUser = (data: any) => {
    if (data.id) {
        return request.put<any, any>(API.UPDATEUSER_URL, data)
    } else {
        return request.post<any, any>(API.ADDUSER_URL, data)
    }
}

// 获取全部的职位的接口
export const reqAllRole = (userId: any) => request.get<any, any>(API.ALLROLE_URL + userId)

// 分配职位的接口
export const reqSetUserRole = (data: any) => request.post<any, any>(API.SETROLE_URL, data)

// 删除某一个账号
export const reqRemoveUser = (userId: any) => request.delete<any, any>(API.DELETEUSER_URL + userId)

// 批量删除的接口
export const reqSlectUser = (idList: any) => request.delete<any, any>(API.DELETEALLUSER_URL, { data: idList })






















